<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2021/6/10
  Time: 21:33
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="utf-8">
    <title>黄山学院-留学生信息管理系统</title>
    <link rel="stylesheet" href="/css/main_style.css" />
    <link rel="stylesheet" href="/css/message.css">
    <script src="/js/main_function.js"></script>
    <script>
        function vacationCheckYet() {
            Ajax.post("/vacation/checkYet", null, function (result) {
                let results = JSON.parse(result);
                if (results.code == "100") {
                    let datas = results.data;
                    let i=0;
                    let show = "<table border='1'>" +
                        "<tr><td>学号</td><td>班级</td><td>请假原因</td><td>开始时间</td><td>结束时间</td><td>合计天数</td><td>目的地</td><td>审批意见</td></tr>";
                    for (; datas[i] != null; i++) {
                        let id=datas[i].user_id;
                        show = show +
                            "<tr>" +
                            "<td>" + id + "</td>" +
                            "<td>" + datas[i].classes + "</td>" +
                            "<td>" + datas[i].reason + "</td>" +
                            "<td>" + formatDate(new Date(datas[i].begin_time)) + "</td>" +
                            "<td>" + formatDate(new Date(datas[i].end_time)) + "</td>" +
                            "<td>" + datas[i].duration_time + "</td>" +
                            "<td>" + datas[i].destination + "</td>" +
                            "<td><button onclick= 'vacationDeal(\""+id+"\",1)'>通过</button>/<button onclick='vacationDeal(\""+id+"\",0)'>驳回</button></td>" +
                            "</tr>"
                        ;
                    }
                    show = show + "</table>";
                    if(i!=0){
                        document.getElementById("vacation-content").innerHTML = show;
                    }
                }
            })
        }

        function vacationDeal(user_id, advice) {
            let data= '{' + "\"user_id\":\"" + user_id + "\"," + "\"advice\":\""+advice+"\"" + '}';
            Ajax.post("/vacation/deal", data, function (result) {
                let results = JSON.parse(result);
                if (results.code == "100") {
                    document.location.reload();
                }
            })
        }
    </script>
    <style>
        table{
            width: 100%;
            border-top: 1px solid #999;
            border-left: 1px solid #999;
            border-spacing: 0;
        }
    </style>
</head>
<body onload="vacationCheckYet()">
<div id="navigation">
    <div class="navigation-left"><img src="/img/school.png" style="width: 170px;height: 60px;"></img></div>
    <div class="navigation-center"><a>事假管理</a></div>
    <div class="navigation-right">
        <div class="drop-menu" style="float:right;">
            <div class="user-menu"></div>
            <div class="drop-menu-content">
                <a href="/logout">注销登录</a>
                <a href="/rePassword">修改密码</a>
            </div>
        </div>
    </div>
</div>
<div id="broadside">
    <div class="broadside-logo">
        <h1>欢迎教师</h1>
        <p>工号${user_id}</p>
    </div>
    <div class="broadside-menu">
        <p><img src="/img/home.png"/><a href="/teacher/home">首页</a></p>
        <p><img src="/img/manager.png"/><a href="/teacher/manager">学生信息管理</a></p>
        <p><img src="/img/vacation.png"/><a href="/teacher/vacation">事假管理</a></p>
        <p><img src="/img/scholarship.png"/><a href="/teacher/scholarship">奖学金审核</a></p>
        <p><img src="/img/message.png"/><a href="/teacher/message ">留言板</a></p>
    </div>
</div>
<div id="content">
    <div class="title"><p>当前所有未处理请假信息</p></div>
    <div id="vacation-content">无</div>
</div>
</body>
</html>
